<?php
/**
 * Created by PhpStorm.
 * User: acer
 * Date: 2017/9/4
 * Time: 13:48
 */

namespace App\Http\Controllers\Home;
use App\Models\Login;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Session;

class LoginController extends BaseController
{
    /**
     * 初始化
     * RegisterController constructor.
     * @param Register $register
     */
    public function __construct(Login $login)
    {
        parent::__construct();
        $this->login = $login;
    }

    /**
     * 用户登录
     */
   public function getLogin(){
       return view('home/recharge/login');
   }

    public function postLogin(){
        $res = $this->login->login(request());
        if ($res['state'] == 0 || $res['state'] == 400 ) {
            return redirect()->back()->with('message', $res['msg'])->withInput();
        }
        if ($res['state'] == 200){
            return redirect('/');
        }

    }


    /**
     * 退出
     */
    public function getLogout()
    {
//        Auth::logout();
        Session::forget('uid');
        return redirect('login');
    }


}